//index.js
//获取应用实例
const Http=require('../../models/HTTP')
const app = getApp()

Page({
  
  data: {
    offset:0,
    playlists:[] 
  },
  onLoad(){
    // Http.getCatData(this.data.offset).then(res=>{
    //   var playlists=res.data.playlists
    //   console.log(playlists)
    //   this.setData({
    //     playlists
    //   })
    // })
    var This=this;
    (async function(){
      var res=await Http.getCatData(This.data.offset);
      console.log(res)
      playlists=res.data.playlists
      This.setData({
        playlists
      })
    })()
  }, 
  onReachBottom(){
    var This=this;
    var offset=this.data.offset;
    offset+=35;
  // Http.getCatData(offset).then(res=>{
  //   var {playlists}=res.data;
  //   console.log(playlists)
  //   this.setData({
  //     offset,
  //     playlists:this.data.playlists.concat(playlists)
  //   })
  // })
    (async function(){
      var res= await Http.getCatData(offset);
      var {playlists}=res.data;
      console.log(playlists);
      This.setData({
        offset,
        playlists:This.data.playlists.concat(playlists)
      })

    })()
  }
})
